package com.qyer.commons.concurrent.assemblingline.creator;

import com.qyer.commons.concurrent.assemblingline.ProcessMode;
import org.apache.commons.lang3.ArrayUtils;

/**
 * User: Z J Wu Date: 2016/06/12 Time: 18:37 Package: com.qyer.commons.concurrent.assemblingline
 * .creator
 */

public class BasicStatisticCreator implements InstanceCreator<BasicStatistic> {

  private static class InnerHolder {

    private static final BasicStatisticCreator INSTANCE = new BasicStatisticCreator();
  }

  private BasicStatisticCreator() {
  }

  public static BasicStatisticCreator getInstance() {
    return InnerHolder.INSTANCE;
  }

  @Override
  public BasicStatistic create(Object... params) {
    return ArrayUtils.isEmpty(params) ? new BasicStatistic()
                                      : new BasicStatistic((ProcessMode) params[0]);
  }
}
